class Dep {
  constructor() {
    this.sub = [];
  }
	// 收集观察者
  addSub(watcher) {
    if (watcher && watcher.update) {
      this.sub.push(watcher);
    }
  }
	// 通知观察者更新视图
  notify(value) {
    this.sub.forEach((watcher) => {
      watcher.update(value);
    });
  }
}
